<template>
  <div id="app">
    <h2>测试题</h2>
    <SubjectItem @submit="submitfn"></SubjectItem>
    <div>
      <FlagItem :resArr="resArr"></FlagItem>
    </div>
  </div>
</template>

<script>
import SubjectItem from './components/SubjectItem.vue'
import FlagItem from './components/FlagItem.vue'
export default {
  data() {
    return {
      resArr: []
    }
  },
  components: {
    SubjectItem,
    FlagItem
  },
  methods: {
    submitfn(val1, val2) {
      console.log(val1, val2)
      if (val1 === val2) {
        this.resArr.push({
          status: '回答正确',
          classAttr: right
        })
      } else {
        if (val2 === 'undefined') {
          this.resArr.push({
            status: '未完成',
            classAttr: undo
          })
        } else {
          this.resArr.push({
            status: '回答错误',
            classAttr: error
          })
        }
      }
    }
  }
};
</script>

<style>
body {
  background-color: #eee;
}

#app {
  background-color: #fff;
  width: 500px;
  margin: 50px auto;
  box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
  padding: 2em;
}
</style>